home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / dev / lang / Python16.lha / Python-1.6 / Lib / Python1.6 / distutils / command / build.py < prev    next >
Encoding:
Python Source  |  2000-06-24  |  4.2 KB  |  123 lines

  1. """distutils.command.build
  2.  
  3. Implements the Distutils 'build' command."""
  4.  
  5. # created 1999/03/08, Greg Ward
  6.  
  7. __revision__ = "$Id: build.py,v 1.25 2000/06/24 01:23:37 gward Exp $"
  8.  
  9. import sys, os
  10. from distutils.core import Command
  11. from distutils.util import get_platform
  12.  
  13.  
  14. def show_compilers ():
  15.     from distutils.ccompiler import show_compilers
  16.     show_compilers()
  17.  
  18.  
  19. class build (Command):
  20.  
  21.     description = "build everything needed to install"
  22.  
  23.     user_options = [
  24.         ('build-base=', 'b',
  25.          "base directory for build library"),
  26.         ('build-purelib=', None,
  27.          "build directory for platform-neutral distributions"),
  28.         ('build-platlib=', None,
  29.          "build directory for platform-specific distributions"),
  30.         ('build-lib=', None,
  31.          "build directory for all distribution (defaults to either " +
  32.          "build-purelib or build-platlib"),
  33.         ('build-scripts=', None,
  34.          "build directory for scripts"),
  35.         ('build-temp=', 't',
  36.          "temporary build directory"),
  37.         ('compiler=', 'c',
  38.          "specify the compiler type"),
  39.         ('debug', 'g',
  40.          "compile extensions and libraries with debugging information"),
  41.         ('force', 'f',
  42.          "forcibly build everything (ignore file timestamps)"),
  43.         ]
  44.  
  45.     help_options = [
  46.         ('help-compiler', None,
  47.          "list available compilers", show_compilers),
  48.     ]
  49.  
  50.     def initialize_options (self):
  51.         self.build_base = 'build'
  52.         # these are decided only after 'build_base' has its final value
  53.         # (unless overridden by the user or client)
  54.         self.build_purelib = None
  55.         self.build_platlib = None
  56.         self.build_lib = None
  57.         self.build_temp = None
  58.         self.build_scripts = None
  59.         self.compiler = None
  60.         self.debug = None
  61.         self.force = 0
  62.  
  63.     def finalize_options (self):
  64.  
  65.         # Need this to name platform-specific directories, but sys.platform
  66.         # is not enough -- it only names the OS and version, not the
  67.         # hardware architecture!
  68.         self.plat = get_platform ()
  69.  
  70.         # 'build_purelib' and 'build_platlib' just default to 'lib' and
  71.         # 'lib.<plat>' under the base build directory.  We only use one of
  72.         # them for a given distribution, though --
  73.         if self.build_purelib is None:
  74.             self.build_purelib = os.path.join (self.build_base, 'lib')
  75.         if self.build_platlib is None:
  76.             self.build_platlib = os.path.join (self.build_base,
  77.                                                'lib.' + self.plat)
  78.  
  79.         # 'build_lib' is the actual directory that we will use for this
  80.         # particular module distribution -- if user didn't supply it, pick
  81.         # one of 'build_purelib' or 'build_platlib'.
  82.         if self.build_lib is None:
  83.             if self.distribution.ext_modules:
  84.                 self.build_lib = self.build_platlib
  85.             else:
  86.                 self.build_lib = self.build_purelib
  87.  
  88.         # 'build_temp' -- temporary directory for compiler turds,
  89.         # "build/temp.<plat>"
  90.         if self.build_temp is None:
  91.             self.build_temp = os.path.join (self.build_base,
  92.                                             'temp.' + self.plat)
  93.         if self.build_scripts is None:
  94.             self.build_scripts = os.path.join (self.build_base, 'scripts')
  95.     # finalize_options ()
  96.  
  97.  
  98.     def run (self):
  99.  
  100.         # For now, "build" means "build_py" then "build_ext".  (Eventually
  101.         # it should also build documentation.)
  102.  
  103.         # Invoke the 'build_py' command to "build" pure Python modules
  104.         # (ie. copy 'em into the build tree)
  105.         if self.distribution.has_pure_modules():
  106.             self.run_command ('build_py')
  107.  
  108.         # Build any standalone C libraries next -- they're most likely to
  109.         # be needed by extension modules, so obviously have to be done
  110.         # first!
  111.         if self.distribution.has_c_libraries():
  112.             self.run_command ('build_clib')
  113.  
  114.         # And now 'build_ext' -- compile extension modules and put them
  115.         # into the build tree
  116.         if self.distribution.has_ext_modules():
  117.             self.run_command ('build_ext')
  118.  
  119.         if self.distribution.has_scripts():
  120.             self.run_command ('build_scripts')
  121.  
  122. # class build
  123.